﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace TXTD.Admin.Framework.Encryption
{
    public class Md5Utils
    {
        /// <summary>
        /// 获取MD5加密字符串
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static string GetMd5String(string source)
        {
            MD5 md5 = MD5.Create();
            var bytes = md5.ComputeHash(System.Text.Encoding.GetEncoding("utf-8").GetBytes(source));
            string? result = BitConverter.ToString(bytes);
            result = result.Replace("-", "");
            return result;
        }
        /// <summary>
        /// 获取双MD5加密字符串
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static string GetDoubleMd5String(string source)
        {
            string result = GetMd5String(source);
            result = GetMd5String(result);
            return result;
        }
    }
}
